#include<string>
#include<vector>
using namespace std;

class Solution {
public:
    string optimalDivision(vector<int>& nums) {
        string res = to_string(nums[0]);
        if (nums.size() == 1) return res;
        res += "/";
        if (nums.size() != 2) 
            res += "(";
        res += to_string(nums[1]);
        for (int i = 2; i < nums.size(); ++i) {
            res += "/" + to_string(nums[i]);
        }
        if (nums.size() != 2)
            res += ")";
        return res;
    }
};